package com.xbn.netty.nio;

import java.nio.IntBuffer;

/**
 * @author XBN
 * @date 2020/10/13 8:16
 * @email 78742541@qq.com
 */
/*
* Buffer缓冲区
* */
public class BasicBuffer {
    public static void main(String[] args) {
        //创建一个允许大小为5的int类型的缓冲区
        IntBuffer buffer=IntBuffer.allocate(5);
        //buffer中放置数据
        for (int i = 1; i < buffer.capacity(); i++) {
            buffer.put(i);
        }
        //将buffer进行读写翻转(读写切换)
        buffer.flip();
        while (buffer.hasRemaining())
            System.out.println(buffer.get());
    }
}
